Developer --> Technical Publications
PATH  Mac OS X Server Documentation > Mac OS X Server Release Notes


[Back]

Rhapsody Developer Release Copyright 1997 Apple Computer, Inc. All Rights Reserved.

NSDirectPalette

 

Inherits From: NSObject

Conforms To: NSCoding, NSCopying

Declared In: Interceptor/NSDirectPalette.h

 

Class Description

An NSDirectPalette provides a representation of the color palette of the display when a system is running in 8-bit pseudocolor mode. The NSDirectPalette object is used in programs that take over the entire display from the Window Server, using the NSDirectScreen object to reconfigure the display.

The NSDirectPalette caches and vends machine-specific palette data as an NSData object through the rawMachinePalette method. The contents and layout of this NSData object will change across different platforms and versions of the NSDirectPalette and NSDirectScreen objects. The rawMachinePalette method is intended for use primarily by NSDirectScreen objects in the initial release.

Manipulation of an NSDirectPalette instance does not affect the hardware display. The palette must be explicitly sent to a NSDirectScreen instance in a setPalette: or setPaletteAtNextBlankingInterval: message in order to affect a hardware display.

 

Method Types

Obtaining a default palette
+ defaultPalette
 
Creating an NSDirectPalette
- init
- initWithArrayOfColors:
 
Enumerating an NSDirectPalette
- objectEnumerator
 
Querying a palette
- count
- colorAtIndex:
- indexForColor:
- getRed:green:blue:atIndex:
 
Setting a palette
- setColor:atIndex:
- setColors:atIndices:
- setRed:green:blue:atIndex:
 
Blending a palette and a color
- blendedPaletteWithFraction:ofColor:
 

Class Methods

defaultPalette

+ (NSDirectPalette *)defaultPalette

Returns a default palette. The contents of the palette are platform-specific.

 

Instance Methods

blendedPaletteWithFraction:ofColor:

- (NSDirectPalette *)blendedPaletteWithFraction:(float)fraction ofColor:(NSColor *)color

Returns a palette whose colors are a blend of the colors in this palette and the color parameter. Each color in the current palette is blended with the color represented by the color object, and entered in the returned palette. The degree of blending is controlled by thefraction value. A fraction of 0.0 results in a copy of the current palette, while a fraction of 1.0 results in a palette with all entries consisting of color .

 

colorAtIndex:

- (NSColor *)colorAtIndex:(int)index

Returns the NSColor object stored at index in the palette.

 

count

- (unsigned)count

Returns the number of colors used in this palette.

 

getRed:green:blue:atIndex:

- (void)getRed:(float *)pRed green:(float *)pGreen blue:(float *)pBlue atIndex:(float *)idex

Returns the red, green, and blue color values for the NSColor object stored at index in the palette.

 

indexForColor:

- (int)indexForColor:(NSColor *)color

Returns the palette index that best represents color. Gray values are preferentially matched to indices for gray values in the palette.

 

init

- (NSDirectPalette *)init

Initializes a default palette. The contents of the palette are platform-specific.

 

initWithArrayOfColors:

- (NSDirectPalette *)initWithArrayOfColors:(NSArray *)colors

Initializes a palette with the NSColor objects stored in the array . Ordering in the palette matches ordering in the array.

 

objectEnumerator

- (NSEnumerator *)objectEnumerator

Returns an enumerator object that lets you access each NSColor in the palette, starting with the first element.

NSEnumerator *enumerator = [myPalette objectEnumerator];
NSColor * aColor;
while (aColor = [enumerator nextObject]) {
/* code to act on each color as it is returned */
}

Your code shouldn't modify the palette during enumeration.

See also: - nextObject (NSEnumerator)

 

rawMachinePalette

- (NSData *)rawMachinePalette

Caches and vends machine-specific palette data, returned as an NSData object. The contents and layout of this NSData object differs between different platforms and versions of the NSDirectPalette and NSDirectScreen objects. The rawMachinePalette method is intended for use primarily by NSDirectScreen objects in the initial release.

 

setColor:atIndex:

- (void)setColor:(NSColor *)color atIndex:(int)index

Sets the color at index to be color . The previous color at index is released.

 

setColors:atIndices:

- (void)setColors:(NSColor **)colors atIndices:(NSRange)indexRange

Sets the colors over the range specified by indexRange from colors . The previous colors in indexRange are released.

 

setRed:green:blue:atIndex:

- (void)setRed:(float)red green:(float)green blue:(float)blue atIndex:(int)index

Set the color at index to be an NSColor object representing red , green , and blue . The previous color at index is released.